from datetime import datetime
from fastapi import (
    FastAPI, Body,
    Header, Cookie,
    Form, File, UploadFile, Path, Query,
    APIRouter
)
from pydantic import BaseModel, Field
from enum import Enum

app = FastAPI()


class BaseEvaluateOut(BaseModel):
    time: datetime = Field(description="提交时间")
    msg: str = Field(description="评论")
    stars: int = Field(ge=1, le=5, description="评分")


class EvaluateOut(BaseModel):
    evaluate: dict[str, BaseEvaluateOut] = Field(description="评论者名字: 对应评论")


class WorkListOut(BaseModel):
    work: int
    time: datetime
    normative: bool = Field(description="是否命名规范")
    out_time: bool = Field(description="是否超时")
    remark: str = Field(description="留言")
    file_name: str = Field(description="作业路径")
    self: int = Field(description="学生表主键")
    checker: list[str] = Field(description="检查者的名字列表")
    evaluate: dict[str, BaseEvaluateOut] = Field(description="评论者名字: 对应评论")
    stars: float = Field(description="平均评分")


class BaseStudentsListOut(BaseModel):
    name: str = Field(description="名字")
    stu_id: str = Field(description="学生号")
    qq_id: str = Field(description="QQ号")
    group: str = Field(description="组名")
    direction: str = Field(description="方向")
    email: str = Field(default=None, description="邮箱")
    phone: str = Field(default=None, description="电话")
    is_senior: bool = Field(description="是否是学长")
    is_root: bool = Field(description="是否是root")
    is_active: bool = Field(description="是否通过注册")
    work_list: dict[int, WorkListOut]


class StudentsListOut(BaseModel):
    student: dict[int, BaseStudentsListOut] = Field(description="学生表id: 信息")


class StudentsListIn(BaseModel):
    name: str = Field(description="名字")
    stu_id: str = Field(description="学生号")
    password: str = Field(description="密码")
    qq_id: str = Field(description="QQ号")
    group: str = Field(description="组名")
    direction: str = Field(description="方向")
    email: str = Field(default=None, description="邮箱")
    phone: str = Field(default=None, description="电话")


class StudentsListFix(BaseModel):
    name: str = Field(default=None, description="名字")
    stu_id: str = Field(default=None, description="学生号")
    password: str = Field(..., description="密码")
    qq_id: str = Field(default=None, description="QQ号")
    group: str = Field(default=None, description="组名")
    direction: str = Field(default=None, description="方向")
    is_active: bool = Field(description="是否通过注册")
    accompany: bool = Field(description="是否陪伴")
    email: str = Field(default=None, description="邮箱")
    phone: str = Field(default=None, description="电话")


class Temp(BaseModel):
    name: str = Field(..., description="作业标题")
    message: str = Field(..., description="作业简介")
    DDL: datetime = Field(..., description="截止日期")


class WorkManageIn(BaseModel):
    name: str = Field(..., description="名字")
    message: str = Field(..., description="作业简介")
    DDL: datetime = Field(..., description="截止日期")
    direction: str = Field(..., description="方向")


class WorkManageFix(BaseModel):
    name: str = Field(..., description="名字")
    message: str = Field(..., description="作业简介")
    DDL: datetime = Field(..., description="截止日期")
    direction: str = Field(..., description="方向")


class WorkManageOut(BaseModel):
    id: dict[str, Temp] = Field(..., description="学生id：信息")


class WorkListIn(BaseModel):
    data: dict[int, WorkListOut] = Field(..., description="学生表id: 信息")


class WorkListFix(BaseModel):
    students_list_pk: str = Field(..., description="学生对应的id")
    work_manage_pk: str = Field(..., description="作业布置表对应的id")
    file_name: str = Field(description="作业路径")
    remark: str = Field(description="留言")
    time: datetime
    group: str = Field(..., description="组别")
    direction: str = Field(..., description="方向")
    normative: bool = Field(description="是否命名规范")
    out_time: bool = Field(description="是否超时")
    checker: list[str] = Field(description="检查者的名字列表")


class WorkListOut_(BaseModel):
    students_list_pk: str = Field(..., description="学生对应的id")
    work_manage_pk: str = Field(..., description="作业布置表对应的id")
    file_name: str = Field(description="作业路径")
    remark: str = Field(description="留言")
    group: str = Field(..., description="组别")
    direction: str = Field(..., description="方向")
    normative: bool = Field(description="是否命名规范")



# 这些接口放后面写
class LoginIn(BaseModel):
    stu_id: int = Field(..., description="学号")
    password: str = Field(..., description="密码")


class LoginReturn(BaseModel):
    stu_id: str = Field(..., description="学号")
    is_senior: bool = Field(description="是否是学长")
    is_root: bool = Field(description="是否是root")
    stage: int = Field(..., description="阶段")


class LoginOut(BaseModel):
    token: str = Field(..., description="token")
    info: dict[str, LoginReturn] = Field(..., description="登录返回值")


class RegisterOut(BaseModel):
    name: str = Field(..., description="名字")
    stu_id: int = Field(..., description="学号")
    password: str = Field(..., description="密码")
    qq_id: str = Field(..., description="qq账号")
    group: str = Field(..., description="组别")
    direction: str = Field(..., description="方向")


class CheckerIn(BaseModel):
    checker: list[str] = Field(description="检查者的名字列表")


class Evaluate(BaseModel):
    name: str = Field(..., description="名字")
    evaluate: str = Field(..., description="评价")
    stars: int = Field(description="评分")


# class


class Download(BaseModel):
    file_name: str = Field(default='开发一组-xxxx-xxx.zip')


@app.get("/")
async def root():
    return {"message": "Hello World"}


class User(BaseModel):
    name: str
    age: int = Field(description="啊实打实的", default=123)


class Choice(Enum):
    asd = 123
    dsa = 233


# @app.post("/hello/")
# async def say_hello(
#         # WorkListIn: dict[int, WorkListOut] = Body(..., description="学生表id: 信息", )
#         # WorkManageIn: dict[str, Temp] = Body(..., description="学生id：信息")
#         # StudentsListOut: StudentsListOut = Body()
#         #     LoginIn: LoginIn = Body()
#
# ):
#     pass

# 群查
@app.get("/StudentsList/")
async def StudentsListOut(
        StudentsListOut: dict[int, BaseStudentsListOut] = Body(...,description="学生表id: 信息")
):
    pass

# 删除
@app.delete(f"/StudentsList/{id}")
async def StudentsListDelete():
    pass

# 改变
@app.put(f"/StudentsList/{id}")
async def StudentsListFix(
        StudentsListFix: StudentsListFix = Body()
):
    pass

# 增加
@app.post("/StudentsList/")
async def StudentsListIn(
        StudentsListIn: StudentsListIn = Body()
):
    pass
#########################################################
# 群查
@app.get("/WorkList/")
async def WorkListIn(
        WorkListIn: dict[int, WorkListOut] = Body(..., description="学生表id: 信息", )
):
    pass
#
# 删除
@app.delete(f"/WorkList/{id}")
async def WorkListDelete():
    pass

# 改变
@app.put(f"/WorkList/{id}")
async def WorkListFix(
        WorkListFix: WorkListFix = Body()
):
    pass

# 增加
@app.post("/WorkList/")
async def WorkListOut_(
        WorkListOut_: WorkListOut_ = Body()
):
    pass
#########################################################
# 群查
@app.get("/WorkManage/")
async def WorkManageOut(
        WorkManageOut: dict[str, Temp]= Body(..., description="学生id：信息")
):
    pass

# 删除
@app.delete(f"/WorkManage/{id}")
async def WorkManageDelete():
    pass

# 改变
@app.put(f"/WorkManage/{id}")
async def WorkManageFix(
        WorkManageFix: WorkManageFix = Body()
):
    pass

# 增加
@app.post("/WorkManage/")
async def WorkManageIn(
        WorkManageIn: WorkManageIn = Body()
):
    pass

@app.post("/Register/")
async def RegisterOut(
        RegisterOut: RegisterOut = Body()
):
    pass

